package com.niocholas.study.designpatterns.chainofresponsibility.normal;

public class NormalHandlerChain {
    private NormalHandler head = null;
    private NormalHandler tail = null;

    public void addHandler(NormalHandler handler) {
        handler.setSuccessor(null);
        if (head == null) {
            head = handler;
            tail = handler;
            return;
        }
        tail.setSuccessor(handler);
        tail = handler;
    }

    public void handle() {
        if (head != null) {
            head.handle();
        }
    }

}